import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { Layout } from 'antd';
import Login from './pages/Login';

const { Content } = Layout;

function App() {
  const token = localStorage.getItem('token');

  return (
    <Router>
      <Layout style={{ minHeight: '100vh' }}>
        <Content>
          <Routes>
            <Route path="/login" element={<Login />} />
            <Route path="/" element={
              token ? (
                <div style={{ padding: '24px' }}>
                  <h1>欢迎来到Green Code</h1>
                </div>
              ) : (
                <Navigate to="/login" replace />
              )
            } />
          </Routes>
        </Content>
      </Layout>
    </Router>
  );
}

export default App;